package com.puppet.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectMQConfig {
    /*
    * 定义direct交换机
    * */
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("direct.exchange");
    }

    /*
    * 创建两个队列
    * */
    @Bean
    public Queue directQueue1(){
        return new Queue("directQueue1");
    }
    @Bean
    public Queue directQueue2(){
        return new Queue("directQueue2");
    }

    /*
    * 绑定两个队列
    * */
    @Bean
    public Binding directBinding1(Queue directQueue1,DirectExchange directExchange){
        return BindingBuilder.bind(directQueue1).to(directExchange).with("gz");
    }
    @Bean
    public Binding directBinding2(Queue directQueue2,DirectExchange directExchange){
        return BindingBuilder.bind(directQueue2).to(directExchange).with("sz");
    }
}
